<?php
session_start();
if (isset($_SESSION["username"])) {
?>
    <?php require_once('common/header.php'); ?>
    <!--页面主要内容-->
    <main class="lyear-layout-content">
        <div class="container-fluid">

            <?php
            include_once("../untils/conn.php");

                $id = $_GET['id'];
                $data = mysqli_query($con, "select * from oder where id=" . $id);
                $rows = mysqli_fetch_row($data);
                $goods = $rows[1];
                
                $sql = "SELECT haokaid FROM list WHERE name='$goods'";
                $res = mysqli_query($con, $sql);
                if(mysqli_num_rows($res) > 0){
                    $row = mysqli_fetch_assoc($res);
                    $haokaid = $row['haokaid'];
                   
                }
                
                $sql = "SELECT * FROM kefu";
                $res = mysqli_query($con, $sql);
                if(mysqli_num_rows($res) > 0){
                    $row = mysqli_fetch_assoc($res);
                    $user_id = $row['appid'];
                    $secret = $row['key'];
                    
                }
                
                //替换计算签名中的秘钥
                $user_sign = md5("Address=".$rows[8]."&Area=".$rows[7]."&City=".$rows[6]."&DownOrderID=".$rows[11]."&IDCard=".$rows[3]."&Name=".$rows[2]."&Phone=".$rows[4]."&ProductID=".$haokaid."&Province=".$rows[5]."&ThirdPhone=&Timestamp=".time()."&user_id=".$user_id.$secret);
                // echo $user_sign;
                // exit;
            ?>
            <div class="card">
                <div class="card-header bg-primary">
                    <h4>提交审核</h4>
                </div>
                <div class="card-body">
                    <form class="form-horizontal" action="https://haokaopenapi.lot-ml.com/api/order/ApiToOrder" method="POST">
                        <div class="form-group">
                            <label for="title" class="col-xs-12">172商品id：</label>
                            <div class="col-xs-12">
                                <input type="text" class="form-control" name="ProductID" placeholder="" value="<?php echo $haokaid ?>" required>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="title" class="col-xs-12">姓名：</label>
                            <div class="col-xs-12">
                                <input type="text" class="form-control" name="Name" placeholder="" value="<?php echo $rows[2] ?>" required>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="title" class="col-xs-12">身份证号：</label>
                            <div class="col-xs-12">
                                <input type="text" class="form-control" name="IDCard" placeholder="" value="<?php echo $rows[3] ?>" required>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="title" class="col-xs-12">手机号码：</label>
                            <div class="col-xs-12">
                                <input type="text" class="form-control" name="Phone" placeholder="" value="<?php echo $rows[4] ?>" required>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="title" class="col-xs-12">省份：</label>
                            <div class="col-xs-12">
                                <input type="text" class="form-control" name="Province" placeholder="" value="<?php echo $rows[5] ?>" required>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="title" class="col-xs-12">城市：</label>
                            <div class="col-xs-12">
                                <input type="text" class="form-control" name="City" placeholder="" value="<?php echo $rows[6] ?>" required>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="title" class="col-xs-12">县区：</label>
                            <div class="col-xs-12">
                                <input type="text" class="form-control" name="Area" placeholder="" value="<?php echo $rows[7] ?>" required>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="title" class="col-xs-12">地址：</label>
                            <div class="col-xs-12">
                                <input type="text" class="form-control" name="Address" placeholder="" value="<?php echo $rows[8] ?>" required>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="title" class="col-xs-12">我方订单id：</label>
                            <div class="col-xs-12">
                                <input type="text" class="form-control" name="DownOrderID" value="<?php echo $rows[11] ?>" placeholder="" required>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="title" class="col-xs-12">计算签名：</label>
                            <div class="col-xs-12">
                                <input type="text" class="form-control" name="user_sign" value="<?php echo $user_sign ?>" placeholder="md5签名" required>
                            </div>
                        </div>
                        <div class="form-group">
                            <input type="hidden" name="user_id" value="<?php echo $user_id ?>">
                            <input type="hidden" name="ThirdPhone" value="">
                            <input type="hidden" name="Timestamp" value="<?php echo time();?>">
                            <input type="hidden" name="secret" value="<?php echo $secret ?>">
                            
                            <div class="offset-2 col-xs-12">
                                <button class="btn btn-success" type="submit" value="添加">提交审核</button>
                            </div>
                        </div>
                    </form>

                </div>
            </div>
        </div>
        </div>
        </div>
        </div>
        </div>


        </div>
    </main>
    <!--End 页面主要内容-->
    <?php require_once('common/footer.php'); ?>
<?php
} else {
    echo "<script>alert('您尚未登录，没有权限访问该页面');location.href='login.php';</script>";
}
